package cn.iocoder.yudao.adminserver.franky.LRU;

import java.util.concurrent.atomic.AtomicLong;

/**
 * @Description: 懒汉式
 * @Author: franky
 * @CreateDate: 2021/4/19 1:25 下午
 * @Version: 1.0
 */
public class Singleton2 {
    private static Singleton2 instance;
    private AtomicLong atomicLong = new AtomicLong(0);
    private Singleton2(){}

    public static synchronized Singleton2 getInstance() {
        if (null == instance) {
            instance = new Singleton2();
        }
        return instance;
    }

    public long getId() {
        return atomicLong.incrementAndGet();
    }
}
